package edu.uc.persistence;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * DBConnect service which fills the variables for the outlined DBConnect method defined in interface IDBConnect
 * This class connects to the database using the JDBC driver contained in this project package
 * The output statements will print obtained variables and any errors as SYSTEM LOGGING. (temporary)!
 * Pushes and syncing will be used to back local database tables to the web.
 * 
 * @author Rozzly
 *
 */
public class DBConnectDAO implements DBConnectInterface {

	DBConnectInterface loginService;

	@Override
	public Connection dbConnect() throws Exception {

		// TODO Auto-generated method stub

		String dbURL = "jdbc:mysql://74.54.73.210:3306/rozzly_FoodView";
		String dbName = "rozzly_fooduser";
		String dbPassword = "P@ssword";

		Connection conn = null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			System.out.println("Loading mSQL driver.");
		}
		catch( Exception e ) {
			System.out.println("Failed to load mSQL driver.");
		}
		try {
			System.out.println("Getting Connection");
			conn = DriverManager.getConnection(dbURL, dbName, dbPassword);
			return conn;
		}
		catch( Exception e ) {
			System.out.println("Connection Error!");
		}
		return conn;
	}
}
